<template>
  <div>
	  <p>default:{{msg}}</p>
	  <p>ref:{{msg2}}</p>
	  <p>reactive:{{count}}</p>
	  <button type="button" @click="addValRef">更改addValRef</button>
  </div>
</template>

<script lang="ts">
import { ref, defineComponent, reactive, toRefs, watch } from 'vue'
export default defineComponent({
  name: 'Test',
  setup(){
	 let msg:number = 100;
	 let msg2 = ref<number>(100);
	
	const {count} = state();
	
	watch(count,(val,oldVal)=>{
		console.log(val,oldVal,'watch')
	})
	return {
		msg,
		msg2,
		count
	};
  },
  methods:{
	  addValRef():void{
		this.count++;
	  }
  }
});

function state(){
	let msg3 = reactive({
		count:100
	});
	
	return toRefs(msg3)
}
</script>

<style scoped>
a {
  color: #42b983;
}

label {
  margin: 0 0.5em;
  font-weight: bold;
}

code {
  background-color: #eee;
  padding: 2px 4px;
  border-radius: 4px;
  color: #304455;
}
</style>
